package net.wanho.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * Author：汤小洋
 * Date：2024-07-26 16:24
 * Description：<描述>
 */
@WebFilter("/hello")
public class HelloFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("HelloFilter初始化。。。。。。");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("HelloFilter在调用目标资源之前，进行处理操作。。。。。。。");

        // 放行
        filterChain.doFilter(servletRequest, servletResponse);

        System.out.println("HelloFilter在调用目标资源之后，进行处理操作。。。。。。。");
    }

    @Override
    public void destroy() {
        System.out.println("HelloFilter销毁。。。。。。。");
    }
}
